import * as YvanUI from "yvan-ui-wotu";

interface INP {
    mode: 'edit' | 'new',
    success: Function
}

interface Ref {

}

export class DemoDialogBasic extends YvanUI.Scope<INP, Ref> {

    main = this.$$({
        t1: '',
        t2: ''
    })

    constructor(param: INP) {
        super(param);
    }

    btnOkClick(sender: YvanUI.Button) {
        sender.loading = true
        setTimeout(() => {
            sender.loading = false
            YvanUI.notifySuccess({message: '内部收到消息，处理成功'})
            this.inParamter.success()
            this.close()

        }, 1000)
    }

    btnCancelClick() {
        this.close()
    }

    vjson = () => new Promise(resolve => {
        setTimeout(() => {
            resolve({
                view: 'dialog',
                title: '基本业务模块',
                width: '70%',
                items: [
                    {
                        view: 'form',
                        items: [
                            {
                                view: 'text',
                                bind: 'main.t1',
                                label: '输入框1',
                            },
                            {
                                view: 'text',
                                bind: 'main.t2',
                                label: '输入框2',
                            },
                            {
                                view: 'text',
                                bind: 'main.t1',
                                label: '输入框1',
                            },
                            {
                                view: 'text',
                                bind: 'main.t2',
                                label: '输入框2',
                            },
                            {
                                view: 'text',
                                bind: 'main.t1',
                                label: '输入框1',
                            },
                            {
                                view: 'text',
                                bind: 'main.t2',
                                label: '输入框2',
                            },
                            {
                                view: 'text',
                                bind: 'main.t1',
                                label: '输入框1',
                            },
                            {
                                view: 'text',
                                bind: 'main.t2',
                                label: '输入框2',
                            }
                        ]
                    }
                ],
                footer: [
                    {
                        view: 'button',
                        text: '确定',
                        icon: 'fa fa-save',
                        type: 'primary',
                        onClick: 'btnOkClick'
                    },
                    {
                        view: 'button',
                        text: '取消',
                        icon: 'fa fa-times',
                        onClick: 'btnCancelClick'
                    }
                ]
            })
        }, 3000)
    })
}